<!--
 * @docName: invoiceVerification.vue
 * @Author: mwl
 * @Date: 11:11
 * @LastEditors: mwl
 * @LastEditTime: 11:11
-->
<template>
  <div class="virifyContent">
    <div class="spin-content" v-if='spinning'>
      <a-spin :spinning="spinning" />
    </div>
    <div class="innerContent">
      <div class="notice_content">
        <p>尊敬的用户：</p>
        <p style="text-indent:2em;">为了降低您企业的潜在风险，并提高您企业持续享受政策的稳定性，现“企业开票”需要进行法人人脸核验，确保所有业务和发票均获得法人授权。</p>
        <p style="text-indent:2em;">您的企业“{{invoiceData.businessName}}”正在进行开票服务申请。</p>
        <p>本次开票金额：{{Math.round(invoiceData.amount * 100)/10000}}元</p>
        <p>发票类型：{{invoiceData.invoiceTypeName}}</p>
        <p>开票内容：{{invoiceData.content}}</p>
        <p>接受服务方信息</p>
        <p>公司名称：{{invoiceData.customerName}}</p>
        <p>税号：{{invoiceData.customerTaxNumber}}</p>
        <p>地址：{{invoiceData.customerAddress}}</p>
        <p>电话号码：{{invoiceData.customerMobile}}</p>
        <!-- 合同开票: checkType 2-验证码校验 3-刷脸  ; -->
        <!--           v-if="(invoiceData.checkType==3&&this.bizType==1)||(invoiceData.checkType==2&&this.bizType==2)"   -->
        <p><a-button size="large" v-if="(invoiceData.checkType==3)" v-prevent-re-click type="primary" class="verifyButton" @click="getUrl">人脸核验授权</a-button></p>
      </div>

    </div>
  </div>
</template>

<script>
import { getBusinessCheckFaceInfo, getPersonRealSwipeUrl } from '@api/invoiceAdminister'

export default {
  name: 'invoiceVerification',
  data (){
    return{
      listQuery: {
        total: 0,
        page: 1,
        limit: 1,
      },
      invoiceData2: {},
      id:'',
      loading:null,
      invoiceData:{},
      spinning: false,
    }
  },
  created() {
    if(this.$route.query.invoiceSerialnum) {
      this.id = this.$route.query.invoiceSerialnum;
      this.getBusinessCheckFaceInfoFun();
    }

  },
  methods:{
    async getBusinessCheckFaceInfoFun(){
      this.spinning = true
      let res = await getBusinessCheckFaceInfo({ invoiceNo: this.id })
      if(!res.success){
        this.$message.warning(res.message);
      }else{
        this.spinning = false
        this.invoiceData = res.result;
      }

    },
    async getUrl() {
      this.spinning = true
      let obj = {};
      obj.name = this.invoiceData.name;
      obj.mobile = this.invoiceData.mobile;
      obj.identity = this.invoiceData.identity;
      obj.bizSerialNum = this.id;
      obj.bizType = 1; //获取url
      let res = await getPersonRealSwipeUrl(obj);
      if(!res.success){
        this.$message.warning(res.message);
      }else{
        this.spinning = false
        if(res.result.url) {
          this.toURL(res.result.url);
        } else {
          this.$message.warning(res.message);
          return;
        }
      }

    },
    toURL(url){
      let downloadElement = document.createElement('a');
      downloadElement.href = url;
      document.body.appendChild(downloadElement);
      downloadElement.click(); //点击
      document.body.removeChild(downloadElement); //移除元素
    },
  }
}
</script>

<style scoped lang='less'>
.spin-content {
  background: #e6f7ffe0;
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 350px 0;
  z-index: 100;
  text-align: center;
}
.virifyContent{
  width: 100%;
  height: 100vh;
  background-color: #f5f5f5;
  box-sizing: border-box;
  overflow: hidden;
  .innerContent {
    margin: 10px;
    padding: 12px;
    border-radius: 8px;
    background-color: #fff;
  }
  .verifyButton {
    width:70%;
    margin: 10px 15%;
  }
  .verifyButton2 {
    width:70%;
    margin: 0 15% 10px;
  }
}
</style>
